import 'package:flutter/material.dart';

class Dash_lineWidget extends StatelessWidget {
  final Axis axis;
  final double dashWidth;
  final double dashHeight;
  final int count;
  final Color color;

  Dash_lineWidget(
      {@required this.axis,
      this.dashHeight = 1,
      this.dashWidth = 1,
      this.count,
      this.color = const Color(0xffff0000)});

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context,BoxConstraints constraints){

        //根据宽度计算个数
        return Flex(
            direction: this.axis,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,//从两端开始
          children: List.generate(this.count, (index){

            return SizedBox(
              width: dashWidth,
              height: dashHeight,
              child: DecoratedBox(decoration: BoxDecoration(
                color: color
              )),
            );
          })

        );

      },

    );
  }
}
